﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CNLTHD_GoogleMapAPI_DTO;
using CNLTHD_GoogleMapAPI_DAO;

namespace CNLTHD_GoogleMapAPI
{
	public partial class DangNhap : System.Web.UI.Page
	{
		protected void Page_Load(object sender, EventArgs e)
		{
			AjaxPro.Utility.RegisterTypeForAjax(typeof(DangNhap), this);

			if (!IsPostBack)
			{
			}
		}

		[AjaxPro.AjaxMethod]
		public bool AjaxDangNhap(string sTenDangNhap, string sMatKhau)
		{
			if (sTenDangNhap == null || sMatKhau == null)
			{
				return false;
			}
			NguoiDung nd = NguoiDungDAO.LayNguoiDung(sTenDangNhap.Trim());

			if (nd == null)
			{
				return false;
			}
			if (nd.MatKhau.Trim() == sMatKhau)
			{

				Session.Add("NguoiDung", nd);

				Session.Add("MaNguoiDung", nd.MaNguoiDung);
				Session.Add("TenDangNhap", nd.TenTaiKhoan.Trim());
				Session.Add("MatKhau", nd.MatKhau.Trim());
				return true;
			}
			else
				return false;
		}

		[AjaxPro.AjaxMethod]
		public void AjaxDangXuat()
		{
			Session.Remove("NguoiDung");

			Session.Remove("MaNguoiDung");
			Session.Remove("TenDangNhap");
			Session.Remove("MatKhau");
		}
	}
}